use premium
GO
ALTER PROCEDURE Sp_Com_Analisis_Calificacion               
@cCodemp Varchar(2),              
@cFecIni varchar(10),              
@cFecFin varchar(10),  
@cproveedor varchar(15),  
@cCalifica varchar(1)      
    
AS    
DECLARE @rangofechas varchar(200)  
DECLARE @wcalifica varchar(200)

if @cCalifica = '9'
BEGIN
	set @wcalifica = " "
END
ELSE
BEGIN
if  @cCalifica = '0'
	BEGIN
	set @wcalifica = " and califica is null "
	END
ELSE
	BEGIN
	set @wcalifica = " and califica = '"+ @cCalifica + "' "
	END
END
  
set @rangofechas = " And CO03FECHA >= Convert(DateTime, '" + @cFecIni + "',103)   
  And CO03FECHA <= Convert(DateTime, '" + @cFecFin + "',103)"  
  
EXECUTE ("select  CO03CODIGO, CO03FECHA, CO03CODPRO,     
rsocial = (select top 1  ccm02nom from  Ccm02Cta where ccm02cod = co03codpro ),    
co03tipMon, co03total, califica = isnull(califica,0)    
from co03docu   
where CO03CODPRO like '"+ @cproveedor + "%' " + @rangofechas + @wcalifica )  
  
-- Ejecuto el Store --  
GO
